package main

import (
	"fmt"
	"time"
)

func pump0(ch chan<- int) {
	for i:=0; ; i++ {
		ch <- i
	}
}

func pump1(ch chan<- int) {
	for i:=1; ; i++ {
		ch <- i
	}
}

func suck(ch0,ch1 <-chan int) {
	for {
		select {
			case v:= <-ch0:
				fmt.Println("got data from channel 0:", v)
			case v:= <-ch1:
				fmt.Println("got data from channel 1:", v)
		}
	}
}

func main() {
	ch0:=make(chan int)
	ch1:=make(chan int)

	go pump0(ch0)
	go pump1(ch1)
	go suck(ch0,ch1)

	time.Sleep(time.Second)
}
